<?php
namespace App\Common\Cla\Weixin\MiniProgram;

use App\Common as com;
use App\Common\Cla\Weixin\MiniProgram as nameMiniProgram;

class OfConfig extends com\Cla\ClaBase {

	private \EasyWeChat\MiniProgram\Application $easyObj;

	/**
	 * @param array $easyConfig
	 */
	public function __construct( private array $easyConfig ) {
		parent::__construct();
	}

	/**
	 * @return array
	 */
	public function getEasyConfig(  ):array {
		return $this->easyConfig;
	}

	/**
	 * 获取微信对象
	 * @return \EasyWeChat\MiniProgram\Application
	 */
	public function getEasyObj(  ):\EasyWeChat\MiniProgram\Application {
		if( ! isset( $this->easyObj ) ){
			$this->easyObj = \EasyWeChat\Factory::miniProgram( $this->getEasyConfig() );
		}
		//
		return $this->easyObj;
	}

	// ===============================
	//
	//
	// 下面为静态方法
	//
	//
	// ===============================

	/**
	 * @return $this
	 * @throws
	 */
	public static function makeAsXXXMiniProgram(  ):self {
		$config = com\Lib\Hyperf::configOrFail( 'web.easyWechat.xxx.miniProgram' );
		//
		return self::make( $config );
	}

}
